package com.wenjunwu.blog.handler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class ExceptionHandlerAdvice {

	static final Logger logger = LoggerFactory.getLogger(ExceptionHandlerAdvice.class);

	@ExceptionHandler(value=Exception.class)
	    public ModelAndView exception(Exception exception){
		  	logger.error("异常信息：{}", exception.getMessage());
	        ModelAndView modelAndView = new ModelAndView("common/error");
	        modelAndView.addObject("errorMessage",exception.getMessage());
	        return modelAndView;
	    }
}
